/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package simhya.model.store.jepstore;
import simhya.model.store.Function;
import java.util.ArrayList;
import simhya.model.store.Store;
import org.nfunk.jep.Variable;
import simhya.matheval.SymbolArray;

/**
 *
 * @author Luca
 */
public class MassActionFunction implements Function {
    private int var1;
    private int var2;
    private int par;
    private Store store;
    private Variable[] variables;
    private Variable[] parameters;

    public MassActionFunction(Store store, int par, int var1, int var2) {
        this.store = store;
        this.var1 = var1;
        this.var2 = var2;
        this.par = par;
        this.store.addExternalFunction(this);
    }

    public void initialize() {
        this.variables = (Variable[])store.getVariables();
        this.parameters = (Variable[])store.getParameters();
    }

    public double compute() {
       return (Double)parameters[par].getValue() * (Double)variables[var1].getValue() * (Double)variables[var2].getValue();
    }

    public double compute(SymbolArray vars) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public ArrayList<Integer> getVariableList() {
        ArrayList<Integer> list = new ArrayList();
        list.add(var1);
        list.add(var2);
        return list;
    }


}


 